import { requestClient } from '#/api/request';

const baseUrl = `/ur_biz/user_profile`;

export interface UserProfile {
  user: {
    avatar: string;
    email: string;
    gender: string;
    loginDate: Date;
    nickname: string;
    phoneNumber: string;
    username: string;
  };
  deptName: string;
  roleGroup: string;
  postGroup: string;
}

/** 修改个人信息 */
export function getProfile() {
  return requestClient.get<UserProfile>(`${baseUrl}`);
}

/** 修改个人信息 */
export function editProfile(data: any) {
  return requestClient.post(`${baseUrl}`, data);
}

/** 手机号修改 */
export function editPhonenumber(
  phoneNumber: string,
  codeId: string,
  smsCode: string,
) {
  return requestClient.post(`${baseUrl}/edit_phonenumber`, {
    phoneNumber,
    codeId,
    smsCode,
  });
}

/** 密码修改 */
export function editPwd(oldPassword: string, newPassword: string) {
  return requestClient.post(`${baseUrl}/edit_password`, {
    oldPassword,
    newPassword,
  });
}

/** 用户头像修改*/
export function editAvatar(url: string) {
  return requestClient.post(`${baseUrl}/edit_avatar`, {
    url,
  });
}
